package com.chenfan.magic.controller;

import com.chenfan.common.exception.BusinessException;
import com.chenfan.magic.exception.MagicException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 过滤器里面抛出的异常前端接口看不到返回,抛出的异常进行捕捉重新抛出
 *
 * @author liuming
 * @date 2021-05-07 15:30
 */
@RestController
public class MagicExceptionController {

    /**
     * 重新抛出异常
     */
    @RequestMapping("/magicException")
    public void expiredJwtException(HttpServletRequest request) throws MagicException {
        throw new BusinessException(500, (String) request.getAttribute("message"));
    }
}
